﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HelpDesk
{
    public partial class Calendario : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
        {
            // Clear the link from this day
            e.Cell.Controls.Clear();

            // Add the custom link
            System.Web.UI.HtmlControls.HtmlGenericControl Link = new System.Web.UI.HtmlControls.HtmlGenericControl();
            Link.TagName = "a";
            Link.InnerText = e.Day.DayNumberText;
            Link.Attributes.Add("href", String.Format("JavaScript:window.opener.document.{0}.value = \'{1:d}\'; window.close();", Request.QueryString["field"], e.Day.Date.ToString("dd/MM/yyyy")));

            // By default, this will highlight today's date.
            if (e.Day.IsSelected)
            {
                e.Cell.BackColor = System.Drawing.Color.LightGreen;
                Link.Attributes.Add("style", this.Calendar1.SelectedDayStyle.ToString());
            }

            // Now add our custom link to the page
            e.Cell.Controls.Add(Link);
        }
    }
}
